package guoanmaker.provider.business.model;

import lombok.*;

/**
 * DESC:
 * Created by JTing on 2017/12/18 15:47
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class ShopCommodity implements Comparable<ShopCommodity>{
    private String id;//商品id
    private String commodityCode;//商品编号
    private String commodityName; //商品名称
    private String commodity_bigimage;//商品大图
    private String commodity_smallimage;//商品小图
    private String synopsis;//商品简介
    private Double finalPrice;//最终价格
    private String cityName;//城市
    private String type;//商品所属大类
    private String cityId;  //城市id
    private String sid;
    private String rid;  //区域id
    private String cityCode;
    private String isBargaining; //是否议价 1:议价 2:不可议价

    //this constructor is for commodities which belong the shop which is followed by user
    public ShopCommodity(String id, String commodityCode, String commodityName, String commodity_smallimage, Double finalPrice,String cityCode) {
        this.id = id;
        this.commodityCode = commodityCode;
        this.commodityName = commodityName;
        this.commodity_smallimage = commodity_smallimage;
        this.finalPrice = finalPrice;
        this.cityCode = cityCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ShopCommodity that = (ShopCommodity) o;
        if (id!=null) {
            if (!id.equals(that.id)) return false;
        }
        if (commodityCode!=null) {
            if (!commodityCode.equals(that.commodityCode)) return false;
        }
        if (commodityName!=null) {
            if (!commodityName.equals(that.commodityName)) return false;
        }
        if (commodity_bigimage!=null) {
            if (!commodity_bigimage.equals(that.commodity_bigimage)) return false;
        }
        if (commodity_smallimage!=null) {
            if (!commodity_smallimage.equals(that.commodity_smallimage)) return false;
        }
        if (synopsis!=null) {
            if (!synopsis.equals(that.synopsis)) return false;
        }
        if (cityName!=null) {
            if (!cityName.equals(that.cityName)) return false;
        }
        if (type!=null) {
            if (!type.equals(that.type)) return false;
        }
        if (cityId!=null) {
            if (!cityId.equals(that.cityId)) return false;
        }
        if (sid!=null) {
            if (!sid.equals(that.sid)) return false;

        }
        if (cityCode!=null) {
            if (!cityCode.equals(that.cityCode)) return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        return result;
    }

    public ShopCommodity(String id, String commodityCode, String commodityName, String commodity_bigimage, String commodity_smallimage, String synopsis, Double finalPrice, String cityName, String type, String cityId, String sid,String isBargaining) {
        this.id = id;
        this.commodityCode = commodityCode;
        this.commodityName = commodityName;
        this.commodity_bigimage = commodity_bigimage;
        this.commodity_smallimage = commodity_smallimage;
        this.synopsis = synopsis;
        this.finalPrice = finalPrice;
        this.cityName = cityName;
        this.type = type;
        this.cityId = cityId;
        this.sid = sid;
        this.isBargaining = isBargaining;
    }


    @Override
    public int compareTo(ShopCommodity o) {
        if (this.finalPrice > o.getFinalPrice()) {
            return 1;
        } else {
            return -1;
        }
    }
}
